/**
 *  文件名:WXEntryActivity.java
 *  修改人:lihangjie
 *  创建时间:2015-9-10 下午2:46:26
 */
package com.sharemob.tinchat.wxapi;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

import com.sharemob.tinchat.thirdparty.weixin.WXConstant;
import com.tencent.mm.sdk.openapi.BaseReq;
import com.tencent.mm.sdk.openapi.BaseResp;
import com.tencent.mm.sdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.sdk.openapi.SendAuth;

/**
 * 
 * <一句话功能简述>
 *
 * @author lihangjie
 * version [版本号,2015-9-10 下午2:46:26]
 * @see    [相关类/方法]
 * @since  [产品/模块版本]
 *
 */
public class WXEntryActivity extends Activity implements IWXAPIEventHandler {
	
	
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		WXConstant.api.handleIntent(getIntent(), this);
	}
	
	 protected void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
         setIntent(intent);
         WXConstant.api.handleIntent(intent, this);
         finish();
     }
	public void onReq(BaseReq arg0) {
		  Toast.makeText(this, "请先安装微信应用", Toast.LENGTH_SHORT).show();
	}

	@Override
	public void onResp(BaseResp resp) {
		 String code = ((SendAuth.Resp) resp).token;
//		 System.out.println("---code:"+code);
		 WXConstant.Access_Token(code);
//		 Toast.makeText(this, code, Toast.LENGTH_SHORT).show();
		 finish();
	}

}
